<?php
session_start();
error_reporting(0);
include "./config/connection.php";
if($_SESSION['username']!="")
{

$cari = (isset($_GET['cari'])) ? filter($_GET['cari']) : '';
?>
<!DOCTYPE html>
<html lang="en">
  <head>
     <? include "./include/isimenu.php"; ?>
	  <? include "./include/js.php"; ?>
        <div class="span9">
          <div class="hero-unit">
             <div class="row">
               <div class="span4 offset4"></div>
               <div class="span4 offset4"></div>
               <div class="span4 offset4">
                 
               </div>
            </div>
            
            <?php
			if(!empty($cari)) $syarat = " AND id_pemesanan like '%$cari%' OR tanggal like '%$cari%' OR nama_pemesan like '%$cari%' OR provinsi like '%$cari%' OR kota like '%$cari%' OR status like '%$cari%'"; 
			else $syarat="";
			$query= "SELECT *
				 FROM pemesanan
				 WHERE 1=1 $syarat ORDER BY id_pemesanan DESC";
		//echo $query;
		$jumData = mysql_num_rows(mysql_query($query));			
	   ?>
			 <div class="search"> 
             <form method="GET" action="">
					<fieldset>
						<input class="text" type="text" name="cari" onblur="if(this.value=='')this.value='pencarian pemesanan...';" onclick="if(this.value=='pencarian pemesanan...')this.value='';" value="pencarian pemesanan..." />
						<input class="submit" type="submit" value="" />
					</fieldset>
				</form>
				</div>
           <?php
				if(!empty($cari)) echo "<p></p><a href='order.php'>Kembali Ke Data Pesanan</a><div style='clear:both'>Ditemukan $jumData data produk dengan kata kunci $cari:</div>";
					?>
					
					<table class="table table-striped">							
						<thead>
							<td><b>NO</b></td>
							<td><b>ID PEMESANAN <b></td>
							<td><b>TANGGAL</b></td>
							<td><b>NAMA PEMESAN</b></td>
							<td><b>STATUS</b></td>
							<td align=right><b>AKSI</b></td>
						</thead>
		<?php	
		$item_per_page=10; 
		$offset=paging($item_per_page); $q=$query." LIMIT $offset, $item_per_page";	
		$r=mysql_query($q) or die("Error: Query GAGAL"); $n=mysql_num_rows($r); $no=1;
		if($n>0){
			while($row=mysql_fetch_array($r)){
		?>
		<tr>
			<td><?php echo ($no+$offset);?></td>
            <td><?php echo $row[0];?></td>
            <td><?php echo $row[1];?></td>
			<td><?php echo $row[2];?></td>
            <td><?php echo $row[8];?></td>
            <td>
			&nbsp;&nbsp;&nbsp;&nbsp;<a href='order_detail.php?id_pemesanan=<?php echo $row[0];?>' >Detail</a>
			</td>
        </tr>
	<?php
			$no++;
			}
		}	 
		else{
			if(!empty($cari)) $str="Tidak ada data dengan kata kunci <strong>$cari</strong>";
			else $str="Tidak ada data";
			echo "<tr><td colspan='7' align='center'>$str</td></tr>";
		}
			
			echo "</table>";
			echo_paging($jumData,"order.php?cari=$cari&",$item_per_page);

				
						?>   
          </div>
          
          </div><!--/row-->

         
          </div><!--/row-->
        </div><!--/span-->
      </div><!--/row-->
      </div>	

      <hr>

   <? include "./include/menubawah.php"; ?>
    <?php
    ?>
  </body>
</html>
<?php
    }
else {
    include 'warning.php';
}
?>